package com.spic.business.ioc.controller;

import com.spic.business.ioc.domain.IocDustConcentration;
import com.spic.business.ioc.service.IIocDustConcentrationService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 粉尘浓度数据IOCController
 *
 * @author spic
 * @date 2022-04-14
 */
@RestController
@RequestMapping("/ioc/concentration")
public class IocDustConcentrationController extends BaseController
{
    @Autowired
    private IIocDustConcentrationService iocDustConcentrationService;

    /**
     * 查询粉尘浓度数据IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:concentration:list")
    @GetMapping("/list")
    public TableDataInfo list(IocDustConcentration iocDustConcentration)
    {
        startPage();
        List<IocDustConcentration> list = iocDustConcentrationService.selectIocDustConcentrationList(iocDustConcentration);
        return getDataTable(list);
    }

    /**
     * 导出粉尘浓度数据IOC列表
     */
//    @PreAuthorize(hasPermi = "ioc:concentration:export")
//    @Log(title = "粉尘浓度数据IOC", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IocDustConcentration iocDustConcentration) throws IOException
    {
        List<IocDustConcentration> list = iocDustConcentrationService.selectIocDustConcentrationList(iocDustConcentration);
        ExcelUtil<IocDustConcentration> util = new ExcelUtil<IocDustConcentration>(IocDustConcentration.class);
        util.exportExcel(response, list, "粉尘浓度数据IOC数据");
    }

    /**
     * 获取粉尘浓度数据IOC详细信息
     */
//    @PreAuthorize(hasPermi = "ioc:concentration:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(iocDustConcentrationService.selectIocDustConcentrationById(id));
    }

    /**
     * 新增粉尘浓度数据IOC
     */
//    @PreAuthorize(hasPermi = "ioc:concentration:add")
//    @Log(title = "粉尘浓度数据IOC", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IocDustConcentration iocDustConcentration)
    {
        return toAjax(iocDustConcentrationService.insertIocDustConcentration(iocDustConcentration));
    }

    /**
     * 修改粉尘浓度数据IOC
     */
//    @PreAuthorize(hasPermi = "ioc:concentration:edit")
//    @Log(title = "粉尘浓度数据IOC", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IocDustConcentration iocDustConcentration)
    {
        return toAjax(iocDustConcentrationService.updateIocDustConcentration(iocDustConcentration));
    }

    /**
     * 删除粉尘浓度数据IOC
     */
//    @PreAuthorize(hasPermi = "ioc:concentration:remove")
//    @Log(title = "粉尘浓度数据IOC", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(iocDustConcentrationService.deleteIocDustConcentrationByIds(ids));
    }
}
